package jwlee.testproxy.autoproxy;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * 自动代理
 */
public class LogAround implements MethodInterceptor {
	private Logger logger = Logger.getLogger(this.getClass().getName());

	@Override
	public Object invoke(MethodInvocation mi) throws Throwable {
		logger.log(Level.INFO, mi.getArguments()[0] + " 审核数据开始....");
		try {
			Object result = mi.proceed();
			// 返回值即是被调用的方法的返回值
			return result;
		} finally {
			logger.log(Level.INFO, mi.getArguments()[0] + " 审核数据结束....");
		}
	}
}
